N = 1#int(raw_input())
for _ in range(N):
    nCol, nRow, nLadder, nJump = 5, 5, 3, 2 #map(int,raw_input().split(' '))
    cave = [None]*nRow
    tmp = [
'##--#',
'###--',
'----#',
'--#-#',
'###--']
    for r in range(nRow):
        cave[r] = tmp[r]#raw_input()
    dp = [[None for _ in range(nCol)] for _ in range(nRow)]
    def traverse(r, c, jump):
        if jump<0: return
        if not (0<=r<nRow and 0<=c<nCol): return
        if cave[r][c]=='-': return
        if dp[r][c]==None or dp[r][c]<jump:
            dp[r][c]=jump
            # walk
            traverse(r,c+1, jump)
            traverse(r,c-1, jump)
            # ladder
            for i in range(nLadder):
                traverse(r+i,c, jump)
                traverse(r-i,c, jump)
            # jump
            if c+1<nCol and cave[r][c+1]=='-': traverse(r,c+2,jump-1)
            if c-1>=0 and cave[r][c-1]=='-': traverse(r,c-2,jump-1)
    traverse(0,0,nJump)
    cnt = 0
    for r in range(nRow):
        for c in range(nCol):
            if dp[r][c]!=None: cnt+=1
    print(cnt)